package o;

import android.os.Build.VERSION;
import android.os.Bundle;
import android.text.style.ClickableSpan;
import android.util.SparseArray;
import android.view.View;
import android.view.View.AccessibilityDelegate;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeProvider;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.d;
import androidx.core.view.ViewCompat;
import java.lang.ref.WeakReference;
import java.util.Collections;
import java.util.List;
import o.in.b;

public class hc {
    private static final AccessibilityDelegate ˎ = new AccessibilityDelegate();
    private final AccessibilityDelegate ˏ;
    private final AccessibilityDelegate ॱ;

    public static final class e extends AccessibilityDelegate {
        final hc ˋ;

        e(hc hcVar) {
            this.ˋ = hcVar;
        }

        public boolean dispatchPopulateAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
            return this.ˋ.ॱ(view, accessibilityEvent);
        }

        public void onInitializeAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
            this.ˋ.ˎ(view, accessibilityEvent);
        }

        public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfo accessibilityNodeInfo) {
            in ॱ = in.ॱ(accessibilityNodeInfo);
            ॱ.ͺ(ViewCompat.ˋᐝ(view));
            ॱ.ʻॱ(ViewCompat.ˌ(view));
            ॱ.ʼ(ViewCompat.ˎˎ(view));
            this.ˋ.ˋ(view, ॱ);
            ॱ.ॱ(accessibilityNodeInfo.getText(), view);
            List ॱ2 = hc.ॱ(view);
            for (int i = 0; i < ॱ2.size(); i++) {
                ॱ.ˏ((b) ॱ2.get(i));
            }
        }

        public void onPopulateAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
            this.ˋ.ˊ(view, accessibilityEvent);
        }

        public boolean onRequestSendAccessibilityEvent(ViewGroup viewGroup, View view, AccessibilityEvent accessibilityEvent) {
            return this.ˋ.ˋ(viewGroup, view, accessibilityEvent);
        }

        public void sendAccessibilityEvent(View view, int i) {
            this.ˋ.ˊ(view, i);
        }

        public void sendAccessibilityEventUnchecked(View view, AccessibilityEvent accessibilityEvent) {
            this.ˋ.ˏ(view, accessibilityEvent);
        }

        @RequiresApi(16)
        public AccessibilityNodeProvider getAccessibilityNodeProvider(View view) {
            im ˋ = this.ˋ.ˋ(view);
            return ˋ != null ? (AccessibilityNodeProvider) ˋ.ˎ() : null;
        }

        public boolean performAccessibilityAction(View view, int i, Bundle bundle) {
            return this.ˋ.ˊ(view, i, bundle);
        }
    }

    public hc() {
        this(ˎ);
    }

    @RestrictTo({d.ॱ})
    public hc(AccessibilityDelegate accessibilityDelegate) {
        this.ॱ = accessibilityDelegate;
        this.ˏ = new e(this);
    }

    public AccessibilityDelegate ˊ() {
        return this.ˏ;
    }

    public void ˊ(View view, int i) {
        this.ॱ.sendAccessibilityEvent(view, i);
    }

    public void ˏ(View view, AccessibilityEvent accessibilityEvent) {
        this.ॱ.sendAccessibilityEventUnchecked(view, accessibilityEvent);
    }

    public boolean ॱ(View view, AccessibilityEvent accessibilityEvent) {
        return this.ॱ.dispatchPopulateAccessibilityEvent(view, accessibilityEvent);
    }

    public void ˊ(View view, AccessibilityEvent accessibilityEvent) {
        this.ॱ.onPopulateAccessibilityEvent(view, accessibilityEvent);
    }

    public void ˎ(View view, AccessibilityEvent accessibilityEvent) {
        this.ॱ.onInitializeAccessibilityEvent(view, accessibilityEvent);
    }

    public void ˋ(View view, in inVar) {
        this.ॱ.onInitializeAccessibilityNodeInfo(view, inVar.ˏ());
    }

    public boolean ˋ(ViewGroup viewGroup, View view, AccessibilityEvent accessibilityEvent) {
        return this.ॱ.onRequestSendAccessibilityEvent(viewGroup, view, accessibilityEvent);
    }

    public im ˋ(View view) {
        if (VERSION.SDK_INT >= 16) {
            AccessibilityNodeProvider accessibilityNodeProvider = this.ॱ.getAccessibilityNodeProvider(view);
            if (accessibilityNodeProvider != null) {
                return new im(accessibilityNodeProvider);
            }
        }
        return null;
    }

    public boolean ˊ(View view, int i, Bundle bundle) {
        boolean ˎ;
        List ॱ = ॱ(view);
        for (int i2 = 0; i2 < ॱ.size(); i2++) {
            b bVar = (b) ॱ.get(i2);
            if (bVar.ˋ() == i) {
                ˎ = bVar.ˎ(view, bundle);
                break;
            }
        }
        ˎ = false;
        if (!ˎ && VERSION.SDK_INT >= 16) {
            ˎ = this.ॱ.performAccessibilityAction(view, i, bundle);
        }
        if (ˎ || i != ff.d.ˎ) {
            return ˎ;
        }
        return ॱ(bundle.getInt("ACCESSIBILITY_CLICKABLE_SPAN_ID", -1), view);
    }

    private boolean ॱ(int i, View view) {
        SparseArray sparseArray = (SparseArray) view.getTag(ff.d.ˍ);
        if (sparseArray != null) {
            WeakReference weakReference = (WeakReference) sparseArray.get(i);
            if (weakReference != null) {
                ClickableSpan clickableSpan = (ClickableSpan) weakReference.get();
                if (ˏ(clickableSpan, view)) {
                    clickableSpan.onClick(view);
                    return true;
                }
            }
        }
        return false;
    }

    private boolean ˏ(ClickableSpan clickableSpan, View view) {
        if (clickableSpan == null) {
            return false;
        }
        ClickableSpan[] ˊ = in.ˊ(view.createAccessibilityNodeInfo().getText());
        int i = 0;
        while (ˊ != null && i < ˊ.length) {
            if (clickableSpan.equals(ˊ[i])) {
                return true;
            }
            i++;
        }
        return false;
    }

    static List<b> ॱ(View view) {
        List<b> list = (List) view.getTag(ff.d.ˋˋ);
        return list == null ? Collections.emptyList() : list;
    }
}
